﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace spin100_Yww_SDK
{
    class API
    {

        //IntPtr intPtr = Api_AcceptTransfer(Auth_code, robot_wxid, from_wxid, json_msg); 

        //    return (int) intPtr;

        //IntPtr intPtr = Api_GetRobotHeadimgurl(Auth_code, robot_wxid);

        //    return Marshal.PtrToStringAnsi(intPtr);

        //应用ID
        public static int auth_code{ get; set; }
        //应用logo
        public static string Imgbase64
        {
            get
            {
                //图片base64数据不能有data:image/png;base64,这段头部信息
                string Img = @"iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAABp3SURBVGhDfVpnVJVZluXfrDWz1syaNT9m1kzPVOruqu4qu+xSy9IqERAUFRAVEBMqBlTAjCAgIIIBRVBEi6ACEiQIIjnnjOQcBCSImBUxu2efi6+bqanus9Zd33uP933vnnvO2Wfve9F68OABnj17BrG3b9/i1atX6vr+/Xu8e/8OHz58UK/l+reGxp49f457d0fxYvyFej86NIyS/AI8efQITY2NqCotw/DAIPr7+hAbEYWgU/54PDSK3tYOdLS2ob25BZ289nX34O7gEJrrG1BRUoqqsnI1Knm/XAcH7uA5f0tMfv/NmzfQevjwIZ4+fao+fPfunZq0OPLLyf6tIdZ7+zayMzIRczUSNmusYG2+GmuWmWKjhRm2rFkN+y2bkJWRipE7d3AjMha9nV0YuTuCg/Z70FnXhM7GFjTW1aOloRE9HZ0Y6L2NjpZWNNTeUpPXDHGirKgYw3cG8fA+A/Dosfp9zuT/OiIT+3urr/mOZkj0+ri6YmP37yM7NR31VdXoaWtFflY2Yi+FwW7jepjq62KtqTG2W1shLzUNPS3tGOB9EcGhqC+tRH9rJ1rqGtDGiIgDjbfqlRN11TXKudrKKhUZjUPyuqaiEuOcd3/v5O//P0f+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TRD6SPnfXwQfvYsHdHFktlzGZlFWK6tw6Jfr47VzPTmq11G2WA76eQIR5vtSsNbcpWlluQIztrUhJ1+rUox/e+m8zmzYL96HbaYm0Nn2jewX7+J9ZLEbt+A7qZW1eHHqRZfjr8gc3it/rFGVKpsEnYxpcQhaaA9RK4OOqP5hwItiYb0DaEQGkeEYwlBDA04q3SGHHBaGhhizu9/z/T6EeuXGjKd7LD0hzmqqOd++SWd1WYEJFrzYTBjBuZ+9aXaE965ehXWLTOB+759WM6/L9fWxg6LVTCV88VPPmUTTkdbYzP62rsw8fSZSiWRvW/YGwSpcjOzyMhL/nLo00oaIyxbGMUzygWhMSq1xAkZIWf9kRQVqYY4Ijwr7EIgr2fhZr8LO8xXwYJ5P+uLT7FSdz7RbDNamAIudvYqPXS//YYr/i0n/wf12mDGdLXPJdHaT3ojjHnR3Lmw0DNQm9azvvgMhYmpaGltUBOT7dAJppHs6LxiSj2n8JJakSGrLkNYrkTkBR0m7qp+Ip+pYpfmJxOXiIgTAsFyvXw+QKWbj4c7Xj15hJWEXkmthTNmwfD7GYRYfZiz6QWePoXFs75nn1lK57bg2P6DcNpqgw1GRursRIq+nKRxhb4+VrJhrtTVVj0o+uLP6GttwYPRYbx9/UYdLMk/LohaFK1SSC4lxwuy4aEZQl3E4TekRR/YQyQaEin57yEVEY0j0tVT2RzleiXwvNLnI/2yx/SW3KYEc9g3TH6chzlf/m7y+IBptZ4TNpw1S0VJ6IkcN1gvWwbXHbbYt2EDzrEfWbM+pClaEqlW/jSPqOWOoe4uFnc96cUEJlgPIrJkiCrMYTrlJqehODsPpfmFyoFOItRbRkr9TwydvcuCl+Yo0Yi6Eo7/BcXCBot9eLMdAAAAAElFTkSuQmCC";
                return Img;
            }
        }

        #region 动态链接库
        [DllImport("bin\\YWW.dll")]
        
        private static extern IntPtr YW_SendPrivateMsg(int auth_code,string wxid,string Msg);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SendGroupMsg(int auth_code, string Groupwxid, string Msg,string name);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetAppDirectory(int auth_code);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetLoginNick(int auth_code);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetLoginYWid(int auth_code);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetLoginHead(int auth_code);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SetGroupKick(int auth_code, string Groupwxid, string wxid);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SetGroupLeave(int auth_code, string Groupwxid);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SetFriendAddRequest(int auth_code, string wxid,string V1,string V2);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SetGroupAddRequest(int auth_code,string Msg_json);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_AddLog(int auth_code, int type,string Title, string content);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetGroupMemberInfo(int auth_code, string Groupwxid, string wxid);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetGroupMemberList(int auth_code, string Groupwxid);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetFriendsList(int auth_code);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetGroupList(int auth_code);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetStrangerInfo(int auth_code, string wxid);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SendMoments(int auth_code,string Msg);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SnsComment(int auth_code, string wxid, string Dtid,string Msg,int cont);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SnsObjectDetail(int auth_code, string Dtid);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_AddChatRoomMember(int auth_code, string Groupid, string wxid);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_AddUser(int auth_code, string wxid, string Msg,int type);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_CreateChatRoom(int auth_code, string wxid);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_DeleteUser(int auth_code, string wxid);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetMsgVideo(int auth_code,string Msg_json);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetMsgImage(int auth_code, string Msg_json);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetMsgVoice(int auth_code, string Msg_json);

        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetUserQRCode(int auth_code, string wxid);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_MassMessage(int auth_code, string wxid, string Msg);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SayHello(int auth_code, string stranger, string Msg);

        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SetChatroomAnnouncement(int auth_code, string Groupid, string Msg);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SetChatroomName(int auth_code, string Groupid, string Name);

        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SetHeadImage(int auth_code, string path);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SetUserRemark(int auth_code, string wxid, string Remarks);

        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SetFatal(int auth_code, string 错误提示, string 错误代码);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_UpdateVariable(int auth_code, string Update_json);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SendMomentsV2(int auth_code, string Msg, string img_path);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SnsTimeLine(int auth_code, string id);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SnsUserPage(int auth_code, string wxid, string id);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_GetPeopleNearby(int auth_code, double longitude, double latitude);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_SnsObjectOp(int auth_code, string id, int type,int comment_id);

        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_PClogin(int auth_code, string QR, string URL);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_Logout(int auth_code);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_Update(int auth_code, string name);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_AddUserA(int auth_code, string V1, string V2, string Reason,int source);
        [DllImport("bin\\YWW.dll")]

        private static extern IntPtr YW_TransferOperation(int auth_code, string Msg_json);

        #endregion

        #region 接口方法调用

        /// <summary>
        ///  发送好友消息
        /// </summary>
        /// <param name="wxid">微信ID</param>
        /// <param name="Msg">内容</param>
        /// <returns></returns>
        public static string SendPrivateMsg(string wxid, string Msg)
        {
            IntPtr intPtr = YW_SendPrivateMsg(auth_code, wxid,Msg);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 发送群消息
        /// </summary>
        /// <param name="Groupwxid">群ID</param>
        /// <param name="Msg">内容</param>
        /// <param name="name">AT目标,要AT的人，多个用换行符增加</param>
        /// <returns></returns>
        public static string SendGroupMsg(string Groupwxid, string Msg, string name)
        {
            IntPtr intPtr = YW_SendGroupMsg(auth_code, Groupwxid, Msg, name);

            return Marshal.PtrToStringAnsi(intPtr);

       
        }
        /// <summary>
        /// 返回目录文本
        /// </summary>
        /// <returns></returns>
        public static string GetAppDirectory()
        {
            IntPtr intPtr = YW_GetAppDirectory(auth_code);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// 取登录昵称
        /// </summary>
        /// <returns></returns>
        public static string GetLoginNick()
        {
            IntPtr intPtr = YW_GetLoginNick(auth_code);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        ///  取登录账号
        /// </summary>
        /// <returns></returns>
        public static string GetLoginYWid()
        {
            IntPtr intPtr = YW_GetLoginYWid(auth_code);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 取登录头像URL
        /// </summary>
        /// <returns></returns>
        public static string GetLoginHead()
        {
            IntPtr intPtr = YW_GetLoginHead(auth_code);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 删除群员
        /// </summary>
        /// <param name="Groupwxid"></param>
        /// <param name="wxid"></param>
        /// <returns></returns>
        public static string SetGroupKick(string Groupwxid, string wxid)
        {
            IntPtr intPtr = YW_SetGroupKick(auth_code, Groupwxid, wxid);

            return Marshal.PtrToStringAnsi(intPtr);

          
        }
        /// <summary>
        /// 退出群
        /// </summary>
        /// <param name="Groupwxid">群ID</param>
        /// <returns></returns>
        public static string SetGroupLeave(string Groupwxid)
        {
            IntPtr intPtr = YW_SetGroupLeave(auth_code, Groupwxid);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// s设置好友添加请求
        /// </summary>
        /// <param name="wxid">好友ID</param>
        /// <param name="V1"></param>
        /// <param name="V2"></param>
        /// <returns></returns>
        public static string SetFriendAddRequest(string wxid, string V1, string V2)
        {
            IntPtr intPtr = YW_SetFriendAddRequest(auth_code, wxid, V1, V2);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 置群添加请求
        /// </summary>
        /// <param name="Msg"></param>
        /// <returns></returns>
        public static string SetGroupAddRequest(string Msg_json)
        {
            IntPtr intPtr = YW_SetGroupAddRequest(auth_code, Msg_json);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// 输出日志
        /// </summary>
        /// <param name="type">类型</param>
        /// <param name="Title">标题</param>
        /// <param name="content">内容</param>
        /// <returns></returns>
        public static string AddLog(int type, string Title, string content)
        {
            IntPtr intPtr = YW_AddLog(auth_code, type, Title, content);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// 取群成员信息
        /// </summary>
        /// <param name="Groupwxid">目标所在群群ID</param>
        /// <param name="wxid">微信ID</param>
        /// <returns></returns>
        public static string GetGroupMemberInfo(string Groupwxid, string wxid)
        {
            IntPtr intPtr = YW_GetGroupMemberInfo(auth_code, Groupwxid, wxid);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 取群成员列表
        /// </summary>
        /// <param name="Groupwxid">群ID</param>
        /// <returns></returns>
        public static string GetGroupMemberList(string Groupwxid)
        {
            IntPtr intPtr = YW_GetGroupMemberList(auth_code, Groupwxid);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 取好友列表
        /// </summary>
        /// <returns></returns>
        public static string GetFriendsList()
        {
            IntPtr intPtr = YW_GetFriendsList(auth_code);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// 取群列表
        /// </summary>
        /// <returns></returns>
        public static string GetGroupList()
        {
            IntPtr intPtr = YW_GetGroupList(auth_code);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 取陌生人信息
        /// </summary>
        /// <param name="wxid"></param>
        /// <returns></returns>
        public static string GetStrangerInfo(string wxid)
        {
            IntPtr intPtr = YW_GetStrangerInfo(auth_code, wxid);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 发朋友圈，推荐使用V2
        /// </summary>
        /// <param name="Msg"></param>
        /// <returns></returns>
        public static string SendMoments(string Msg)
        {
            IntPtr intPtr =YW_SendMoments(auth_code,Msg);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 朋友圈消息评论
        /// </summary>
        /// <param name="wxid">微信ID</param>
        /// <param name="Dtid">朋友圈ID,评论哪条</param>
        /// <param name="Msg">评论内容</param>
        /// <param name="cont">commen是否为回复别人,非回复留空</param>
        /// <returns></returns>
        public static string SnsComment(string wxid, string Dtid, string Msg, int cont)
        {
            IntPtr intPtr = YW_SnsComment(auth_code, wxid, Dtid, Msg, cont);

            return Marshal.PtrToStringAnsi(intPtr);

     
        }
        /// <summary>
        /// 获取某条朋友圈消息详情
        /// </summary>
        /// <param name="Dtid">朋友圈消息id</param>
        /// <returns></returns>
        public static string SnsObjectDetail(string Dtid)
        {
            IntPtr intPtr = YW_SnsObjectDetail(auth_code, Dtid);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 添加群成员
        /// </summary>
        /// <param name="Groupid">群ID</param>
        /// <param name="wxid">微信ID</param>
        /// <returns></returns>
        public static string AddChatRoomMember(string Groupid, string wxid)
        {
            IntPtr intPtr = YW_AddChatRoomMember(auth_code, Groupid, wxid);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 添加好友请求
        /// </summary>
        /// <param name="wxid">微信号</param>
        /// <param name="Msg">验证内容</param>
        /// <param name="type">#请求来源_</param>
        /// <returns></returns>
        public static string AddUser(string wxid, string Msg, int type)
        {
            IntPtr intPtr = YW_AddUser(auth_code, wxid, Msg, type);

            return Marshal.PtrToStringAnsi(intPtr);

          
        }
        /// <summary>
        /// 创建群
        /// </summary>
        /// <param name="robwxid">微信ID</param>
        /// <returns></returns>
        public static string CreateChatRoom(string wxid)
        {
            IntPtr intPtr = YW_CreateChatRoom(auth_code, wxid);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 删除好友
        /// </summary>
        /// <param name="wxid">微信ID</param>
        /// <returns></returns>
        public static string DeleteUser(string wxid)
        {
            IntPtr intPtr = YW_DeleteUser(auth_code, wxid);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 获取消息视频
        /// </summary>
        /// <param name="Msg_json">消息原文</param>
        /// <returns></returns>
        public static string GetMsgVideo(string Msg_json)
        {
            IntPtr intPtr = YW_GetMsgVideo(auth_code, Msg_json);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// 获取消息图片
        /// </summary>
        /// <param name="Msg_json">消息原文</param>
        /// <returns></returns>
        public static string GetMsgImage(string Msg_json)
        {
            IntPtr intPtr = YW_GetMsgImage(auth_code, Msg_json);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        ///  获取消息语音（20秒以内为B64不需要取）
        /// </summary>
        /// <param name="Msg_json">消息原文</param>
        /// <returns></returns>
        public static string GetMsgVoice(string Msg_json)
        {
            IntPtr intPtr = YW_GetMsgVoice(auth_code, Msg_json);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// 获取用户二维码
        /// </summary>
        /// <param name="wxid"></param>
        /// <returns></returns>
        public static string GetUserQRCode(string wxid)
        {
            IntPtr intPtr = YW_GetUserQRCode(auth_code, wxid);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// 群发消息
        /// </summary>
        /// <param name="wxid">微信ID,用换行符分割的ID列表</param>
        /// <param name="Msg">内容</param>
        /// <returns></returns>
        public static string MassMessage(string wxid, string Msg)
        {
            IntPtr intPtr = YW_MassMessage(auth_code, wxid, Msg);

            return Marshal.PtrToStringAnsi(intPtr);

           
        }
        /// <summary>
        /// 打招呼
        /// </summary>
        /// <param name="stranger">对方标识</param>
        /// <param name="Msg">内容</param>
        /// <returns></returns>
        public static string SayHello(string stranger, string Msg)
        {
            IntPtr intPtr = YW_SayHello(auth_code, stranger, Msg);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 设置群公告
        /// </summary>
        /// <param name="Groupid">群ID</param>
        /// <param name="Msg">公告内容</param>
        /// <returns></returns>
        public static string SetChatroomAnnouncement(string Groupid, string Msg)
        {
            IntPtr intPtr = YW_SetChatroomAnnouncement(auth_code, Groupid, Msg);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        ///  设置群名
        /// </summary>
        /// <param name="Groupid">群ID</param>
        /// <param name="Name">群名</param>
        /// <returns></returns>
        public static string SetChatroomName(string Groupid, string Name)
        {
            IntPtr intPtr = YW_SetChatroomName(auth_code, Groupid, Name);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 设置头像
        /// </summary>
        /// <param name="path">头像的完整路径</param>
        /// <returns></returns>
        public static string SetHeadImage(string path)
        {
            IntPtr intPtr = YW_SetHeadImage(auth_code, path);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 设置用户备注
        /// </summary>
        /// <param name="wxid">微信ID</param>
        /// <param name="Remarks">备注</param>
        /// <returns></returns>
        public static string SetUserRemark(string wxid, string Remarks)
        {
            IntPtr intPtr = YW_SetUserRemark(auth_code, wxid, Remarks);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 反馈错误提示
        /// </summary>
        /// <param name="错误提示"></param>
        /// <param name="错误代码"></param>
        /// <returns></returns>
        public static string SetFatal(string 错误提示, string 错误代码)
        {
            IntPtr intPtr = YW_SetFatal(auth_code, 错误提示, 错误代码);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// 更新变量数据,通知框架初始化时提供的变量值需要更新
        /// </summary>
        /// <param name="Update_json">json格式{"变量名一"="变量值","变量名二"="变量值"}</param>
        /// <returns></returns>
        public static string UpdateVariable(string Update_json)
        {
            IntPtr intPtr = YW_UpdateVariable(auth_code, Update_json);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// YW_发朋友圈V2
        /// </summary>
        /// <param name="Msg">内容</param>
        /// <param name="img_path">图片文件,换行符分割多张，绝对路径，空文本即不发图片</param>
        /// <returns></returns>
        public static string SendMomentsV2(string Msg, string img_path)
        {
            IntPtr intPtr = YW_SendMomentsV2(auth_code, Msg, img_path);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 取朋友圈动态
        /// </summary>
        /// <param name="id">最后一次获取 的ID，第一次留空</param>
        /// <returns></returns>
        public static string SnsTimeLine(string id)
        {
            IntPtr intPtr = YW_SnsTimeLine(auth_code, id);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// YW_取好友朋友圈
        /// </summary>
        /// <param name="wxid">WXID</param>
        /// <param name="id">最后一次获取 的ID，第一次留空</param>
        /// <returns></returns>
        public static string SnsUserPage(string wxid, string id)
        {
            IntPtr intPtr = YW_SnsUserPage(auth_code, wxid, id);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 获取附近的人
        /// </summary>
        /// <param name="longitude">经度</param>
        /// <param name="latitude">纬度</param>
        /// <returns></returns>
        public static string GetPeopleNearby(double longitude, double latitude)
        {
            IntPtr intPtr = YW_GetPeopleNearby(auth_code, longitude, latitude);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 操作朋友圈
        /// </summary>
        /// <param name="id">朋友圈消息ID</param>
        /// <param name="type">操作类型 1删除 4删除评论 5取消赞</param>
        /// <param name="comment_id">当操作操作类型为4时，指定评论ID</param>
        /// <returns></returns>
        public static string SnsObjectOp(string id, int type, int comment_id)
        {
            IntPtr intPtr = YW_SnsObjectOp(auth_code, id, type, comment_id);

            return Marshal.PtrToStringAnsi(intPtr);
        }
        /// <summary>
        /// 提供登录二维码授权其它设备的登录，只有账号密码登录时才可以调用此功能
        /// </summary>
        /// <param name="QR">二维码图片B64编码（参数只需要提供其中一个，另一个为空文本即可）</param>
        /// <param name="URL">二维码解码后的地址（如果提供了二维码此条无效），此参数设置为：jx  即可解析二维码，返回解析结果</param>
        /// <returns></returns>
        public static string PClogin(string QR, string URL)
        {
            IntPtr intPtr = YW_PClogin(auth_code, QR, URL);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// 退出其它设备的登录
        /// </summary>
        /// <returns></returns>
        public static string Logout()
        {
            IntPtr intPtr = YW_Logout(auth_code);

            return Marshal.PtrToStringAnsi(intPtr);

        }
        /// <summary>
        /// 更新插件
        /// </summary>
        /// <param name="name">新插件文件，必须为yww.dll后缀，插件名不得变动（文件名可以不同）</param>
        /// <returns></returns>
        public static string Update(string name)
        {
            IntPtr intPtr = YW_Update(auth_code, name);

            return Marshal.PtrToStringAnsi(intPtr);


        }
        /// <summary>
        /// 通过V1 V2添加好友
        /// </summary>
        /// <param name="V1"></param>
        /// <param name="V2"></param>
        /// <param name="Reason">申请理由</param>
        /// <param name="source">#请求来源_</param>
        /// <returns></returns>
        public static string AddUserA(string V1, string V2, string Reason, int source)
        {
            IntPtr intPtr = YW_AddUserA(auth_code, V1, V2, Reason, source);

            return Marshal.PtrToStringAnsi(intPtr);


        }
        /// <summary>
        /// 接收转账
        /// </summary>
        /// <param name="Msg_json">转账消息源文</param>
        /// <returns></returns>
        public static string TransferOperation(string Msg_json)//需要设置权限，接收权限75
        {
            IntPtr intPtr = YW_TransferOperation(auth_code, Msg_json);
            JObject retmsg = (JObject)JsonConvert.DeserializeObject(Marshal.PtrToStringAnsi(intPtr));//
            retmsg = (JObject)JsonConvert.DeserializeObject(retmsg["external"].ToString());
            string Retmsg = retmsg["retmsg"].ToString();
            return Retmsg;
        }


        /// <summary>
        /// 根据ID查好友昵称
        /// </summary>
        /// <param name="robot_wxid"></param>
        /// <param name="from_wxid"></param>
        /// <returns></returns>
        public static string nickname(string wxid)
        {
            string Ajson = GetFriendsList();
            try
            {
                JArray jA = (JArray)JsonConvert.DeserializeObject(Ajson);
                for (int i = 0; i < jA.Count; i++)
                {
                    if (jA[i]["user_name"].ToString() == wxid)
                    {
                        return jA[i]["nick_name"].ToString();
                    }
                }
            }
            catch
            { }

            return "微信用户";
        }
        /// <summary>
        /// 根据昵称查询微信ID
        /// </summary>
        /// <param name="robot_wxid"></param>
        /// <param name="from_Name"></param>
        /// <returns></returns>
        public static string wxid(string Name)
        {
            string Ajson = GetFriendsList(); ;
            try
            {
                JArray jA = (JArray)JsonConvert.DeserializeObject(Ajson);
                for (int i = 0; i < jA.Count; i++)
                {
                    if (jA[i]["nick_name"].ToString() == Name)
                    {
                        return jA[i]["user_name"].ToString();

                    }
                }
            }
            catch
            { }

            return null;

        }

        #endregion

    }
    public class YwStudent
    {
        public long ret { get; set; }
        public long apiver { get; set; }
        public string appid { get; set; }
        public string name { get; set; }
        public string version { get; set; }
        public string version_id { get; set; }
        public string author { get; set; }
        public string description { get; set; }
        public string ico { get; set; }
        public long[] permissions { get; set; }
    }

  

}

